<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件的委托</title>
    <style>
      ul {
        width: 300px;
        height: 300px;
        background-color: skyblue;
        list-style: none;
      }
      li {
        width: 50px;
        height: 50px;
        background-color: pink;
        margin-bottom: 10px;
      }
    </style>
</head>
<body>
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
  </ul>
<script>
  //事件的委托 子元素没有事件 父元素有 子元素也可以用到
  var ul = document.querySelector('ul');
  ul.onclick = function (e) {
    console.log('ul被点击');
  }
</script>
</body>
</html>